package com.yigo.prc.app.service;

import com.yigo.prc.api.spu.command.CreateSpuCmd;
import com.yigo.prc.app.assembler.SpuDTO2DmoAssembler;
import com.yigo.prc.domain.spu.entity.PrcSpu;
import com.yigo.prc.domain.spu.repo.PrcSpuRepo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * @author chenzl
 */
@Slf4j
@Service
public class PrcSpuAppService {
    @Resource
    private PrcSpuRepo prcSpuRepo;

    @Transactional(rollbackFor = Exception.class)
    public void createSpu(CreateSpuCmd cmd) {
        PrcSpu prcSpu = SpuDTO2DmoAssembler.INSTANCE.toDmo(cmd);
        prcSpuRepo.save(prcSpu);
    }
}
